package com.ceba.test.base.dbdata.modules;
import com.ceba.base.dbdata.DataTableObject;
import com.ceba.base.dbdata.MysqlUtils;
public class FilesDb {

	public static void init() throws Exception{
		
		//15-start
		DataTableObject g_file=new DataTableObject("g_file");
		g_file.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_file.addField("text_content_id", "varchar(32)", "NOT NULL", "", "true");
		g_file.addField("CONTENT_TYPE", "varchar(100)", "DEFAULT NULL", "", "false");
		g_file.addField("FILE_PATH", "varchar(500)", "DEFAULT NULL", "", "false");
		g_file.addField("FILE_NAME", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file.addField("EXT_NAME", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file.addField("VIRTUAL_PATH", "varchar(1000)", "DEFAULT NULL", "", "false");
		g_file.addField("SIZE", "varchar(1000)", "DEFAULT NULL", "", "false");
		g_file.addField("TEXT_CONTENT", "longtext", "DEFAULT NULL", "", "false");
		g_file.addField("DOCUMENT_TYPE", "varchar(500)", "DEFAULT NULL", "", "false");
		g_file.addField("CREATE_USER", "varchar(500)", "DEFAULT NULL", "", "false");
		g_file.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_file.addField("CLASS", "varchar(100)", "DEFAULT NULL", "", "false");
		g_file.addField("SCOPE", "decimal(19,0)", "DEFAULT NULL", "", "false");
		g_file.addField("REMARK", "longtext", "DEFAULT NULL", "", "false");
		g_file.addField("VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_file.addField("DATA_VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file.addField("QRCODE_FILE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file.addField("STORAGE_ADDRESS_ID", "varchar(32)", "DEFAULT '55555555555555555555555555555555'", "", "false");
		MysqlUtils.syncTableStructure(g_file);
		//end

		DataTableObject g_file_text_content=new DataTableObject("g_file_text_content");
		g_file_text_content.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_file_text_content.addField("TEXT_CONTENT", "longtext", "DEFAULT NULL", "", "false");
		g_file_text_content.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(g_file_text_content);
		
		
		//16-start
		DataTableObject g_file_relaction=new DataTableObject("g_file_relaction");
		g_file_relaction.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_file_relaction.addField("RFLAG", "decimal(19,0)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("RID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("FILE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("FILE_NAME", "varchar(255)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("ITEM_INDEX", "decimal(19,0)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("FOLDER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("USER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("DATA_VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("FLAG", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("SIGN_FILE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction.addField("STORAGE_ADDRESS_ID", "varchar(32)", "DEFAULT '55555555555555555555555555555555'", "", "false");
		MysqlUtils.syncTableStructure(g_file_relaction);
		//end
		
		
		//17-start
		DataTableObject g_file_relaction_delete=new DataTableObject("g_file_relaction_delete");
		g_file_relaction_delete.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_file_relaction_delete.addField("RFLAG", "decimal(19,0)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("RID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("FILE_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("FILE_NAME", "varchar(255)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("ITEM_INDEX", "decimal(19,0)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("FOLDER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("USER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("UPDATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("UPDATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("DATA_VERSION", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("FLAG", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("SIGN_FILE_ID", "varchar(200)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_file_relaction_delete.addField("STORAGE_ADDRESS_ID", "varchar(32)", "DEFAULT '55555555555555555555555555555555'", "", "false");
		MysqlUtils.syncTableStructure(g_file_relaction_delete);
		//end
		
		//18-start
		DataTableObject g_folder=new DataTableObject("g_folder");
		g_folder.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_folder.addField("PID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_folder.addField("NAME", "varchar(5000)", "DEFAULT NULL", "", "false");
		g_folder.addField("FOLDER_NAME", "varchar(1000)", "DEFAULT NULL", "", "false");
		g_folder.addField("RELATION_FOLDER", "text", "DEFAULT NULL", "", "false");
		g_folder.addField("USER_ID", "varchar(32)", "DEFAULT NULL", "", "false");
		g_folder.addField("CREATE_USER", "varchar(32)", "DEFAULT NULL", "", "false");
		g_folder.addField("CREATE_TIME", "datetime", "DEFAULT NULL", "", "false");
		g_folder.addField("CLASS", "varchar(1000)", "DEFAULT NULL", "", "false");
		g_folder.addField("IMG", "varchar(1000)", "DEFAULT NULL", "目录图标", "false");
		g_folder.addField("READ_SQL", "text", "DEFAULT NULL", "", "false");
		g_folder.addField("REPORT_ID", "varchar(255)", "DEFAULT NULL", "报告ID", "false");
		MysqlUtils.syncTableStructure(g_folder);
		//end


		//文件管理表 19-start
		DataTableObject g_storage_address=new DataTableObject("g_storage_address");
		g_storage_address.addField("ID", "varchar(32)", "NOT NULL", "", "true");
		g_storage_address.addField("NAME", "varchar(200)", "NOT NULL", "名称", "false");
		g_storage_address.addField("FILTER", "varchar(100)", "NOT NULL", "过滤器标识", "false");
		g_storage_address.addField("PATH", "varchar(300)", "NOT NULL", "文件所在目录", "false");
		g_storage_address.addField("CAPACITY", "longtext", "NOT NULL", "文件允许存储大小单位M", "false");
		g_storage_address.addField("ACTUAL_SIZE", "longtext", "NOT NULL", "磁盘实际剩余大小单位M", "false");
		g_storage_address.addField("REST", "longtext", "NOT NULL", "剩余大小单位M", "false");
		g_storage_address.addField("STATUS", "varchar(1)", "DEFAULT '1'", "状态：1未开启 2可用 3已满", "false");
		g_storage_address.addField("COPY_FLAG", "varchar(1)", "NOT NULL", "是否拷贝 非表中记录的文件  1 未拷贝 2已拷贝", "false");
		g_storage_address.addField("CREATE_USER", "varchar(32)", "NOT NULL", "", "false");
		g_storage_address.addField("UPDATE_USER", "varchar(32)", "NOT NULL", "", "false");
		g_storage_address.addField("CREATE_TIME", "datetime", "NOT NULL", "", "false");
		g_storage_address.addField("UPDATE_TIME", "datetime", "NOT NULL", "", "false");
		g_storage_address.addField("SPARE1", "varchar(100)", "DEFAULT NULL", "", "false");
		g_storage_address.addField("SPARE2", "varchar(100)", "DEFAULT NULL", "", "false");
		g_storage_address.addField("SPARE3", "varchar(100)", "DEFAULT NULL", "", "false");
		MysqlUtils.syncTableStructure(g_storage_address);

		addIndex();
		insertDefaultData();
	}

	public static void addIndex() throws Exception {
		MysqlUtils.syncFieldIndex("g_file_relaction","FILE_ID");
		MysqlUtils.syncFieldIndex("g_folder","REPORT_ID");
	}
	
	public static void insertDefaultData() throws Exception {
		MysqlUtils.insertDataIntoTable("g_folder","(ID,NAME,USER_ID)","ID","8c1ec0311e4c4881b49190ff84460c16","'8c1ec0311e4c4881b49190ff84460c16','upfile/sign/8c1ec0311e4c4881b49190ff84460c16/','8c1ec0311e4c4881b49190ff84460c16'");
		MysqlUtils.insertDataIntoTable("g_storage_address","(ID,NAME,FILTER,PATH,CAPACITY,ACTUAL_SIZE,REST,STATUS,COPY_FLAG,CREATE_USER,CREATE_TIME,UPDATE_USER,UPDATE_TIME)","ID","55555555555555555555555555555555","'55555555555555555555555555555555','默认存储地址','fileVisit/55555555555555555555555555555555','E:/idsFile',10249,10249,10249,'2','2','99999999999999999999999999999999','2018-09-01 20:00:00','99999999999999999999999999999999','2018-09-01 20:00:00'");
	}
}
